#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<queue>
using namespace std;
typedef struct TreeNode
{
	int val;
	struct TreeNode* left = nullptr;
	struct TreeNode* right = nullptr;
}Node;
void LevelOrder(Node* root) {
	queue<Node*> q;
	q.push(root);
	while (!q.empty()) {
		Node* tmp = q.front();
		if (tmp->left)
			q.push(tmp->left);
		if (tmp->right)
			q.push(tmp->right);
		cout << tmp->val << " ";
		q.pop();
	}
}
void test()
{
	Node* root = new Node, * node1 = new Node,
		* node2 = new Node, * node3 = new Node,
		* node4 = new Node, * node5 = new Node;
	root->val = 5;
	node1->val = 3; root->left = node1;
	node2->val = 6; root->right = node2;
	node3->val = 1; node1->left = node3;
	node4->val = 2; node1->right = node4;
	node5->val = 7; node2->left = node5;
	LevelOrder(root);
}
int main()
{
	test();
	return 0;
}